<html>
<head>
<#import "/common/common.ftl" as netCommon>
<@netCommon.commonStyle />
<title></title>
<@netCommon.commonScript /> 
<@netCommon.commonLayui /> 
</head>
<body class="layui-layout-body show-scroll-y">
	<div class="layuimini-container">
		<form class="layui-form" lay-filter="editFrom" id="editFrom" action="">
			<input type="hidden" name="objectid" id="objectid" value="${objectid!}" />
			<input type="hidden" name="lxjp" id="lxjp" value="${zdLx.lxjp!}" />
			<div class="layui-form-item">
				<label class="layui-form-label">字典类型</label>
				<div class="layui-input-block">
					<input type="text" name="lxmc" lay-verify="required"
						placeholder="请输入"  class="layui-input" value="${zdLx.lxjpmc!}" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">字典代码</label>
				<div class="layui-input-block">
					<input type="text" name="zddm" lay-verify="zddm"
						placeholder="请输入"  class="layui-input" value="" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">字典名称</label>
				<div class="layui-input-block">
					<input type="text" name="zdmc" lay-verify="required"
						placeholder="请输入"  class="layui-input" value="" />
				</div>
			</div>
			<div class="layui-form-item line-center">
				<button type="submit" class="layui-btn" lay-submit lay-filter="saveBtn">保存</button>
				<button type="reset" class="layui-btn layui-btn-primary"  lay-filter="">重置</button>
			</div>
		</form>
	</div>
	<script type="text/javascript">
	layui.use(["form","layer","upload"], function(){
		var layform = layui.form;
		layform.verify({
			"zddm":function(value){
				if(stringUtils.isBlank(value)){
					return "请输入字典代码！";
				}else{
					var errMsg = "";
					var lxjpVal = $("#lxjp").val();
					$.ajax({
						url: basePath+"/zd/validateZddm?lxjp="+lxjpVal+"&zddm="+value,
						type: "post",
						dataType: "json",
						async: false,
						success: function(res){
							if(res.code == "0"){
								if(res.data == false){
									errMsg = res.msg
								}
							}
						}
					});
					return errMsg;
				}
			}
		});
		$("input[name='lxmc']").attr("readonly","readonly");
		$(function(){
			var objId = $("#objectid").val();
			if(objId){
				//获取实体属性对象数据
				$.ajax({
					url: basePath+"/zd/detailByOid?objectid="+objId,
					type: "post",
					dataType: "json",
					success: function(data){
						layform.val('editFrom', {
							"objectid" : data.data.objectid,
							"zddm" : data.data.zddm,
							"zdmc" : data.data.zdmc,
							"lxjp": data.data.lxjp,
							"lxmc" : data.data.lxmc
						});
					}
				});
			}
		});
		
		layform.on("submit(saveBtn)",function(){
			var pData = layform.val('editFrom');
			$.ajax({
				url: basePath+"/zd/doSave",
				type: "post",
				dataType: "json",
				data: pData,    
				success: function(res){
					showMsg.alert(res.msg,function(){
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
						parent.frames[0].loadStsxTable();
					});
				}
			});
			return false;
		});
	});
	</script>
</body>
</html>